// eslint-disable-next-line no-undef
import Vue from "vue";
const files = require.context("./", true, /\.vue$/);
// const files = import.meta.glob("./Tmap/index.vue");
// console.log(files.keys());
const fileList = files.keys();
const component = {};
// console.log();

const registerComponents = () => {
  // console.log(app)
  console.groupCollapsed("注册全局组件");
  fileList.forEach((key) => {
    const keyArr = key.split("/");
    if (keyArr[1] === "layout" || keyArr.length > 3) return;
    const obj = files(key).default;
    if (!obj.name) return;
    // console.log(obj.name || cptName);
    if (component[obj.name]) {
      console.warn(
        obj.name,
        "存在重名的自定义组件，请更改组件命名空间"
      );
      return;
    }
    console.log("@", obj.name, " =>", key);
    component[obj.name] = obj;
  });
  Object.keys(component).forEach((key) => {
    Vue.component(key, component[key]);
  });
  console.groupEnd();
};
registerComponents()
